package com.med.controller;

import com.med.service.SchedulingService;
import com.med.vo.AddSchedulingVO;
import com.med.vo.QueryWorkforceVO;
import com.med.vo.UpdateSchedulingVO;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @BelongsProject: Internet-based-healthcare
 * @BelongsPackage: com.med.controller
 * @Author: 小龚
 * @CreateTime: 2025-08-19 10:07
 * @Description: TODO
 * @Version: 1.0
 */
@RestController
@RequestMapping("/scheduling")
public class SchedulingController extends BaseController {

    private final SchedulingService schedulingService;

    @Autowired
    public SchedulingController(SchedulingService schedulingService) {
        this.schedulingService = schedulingService;
    }

    // 查询排班信息
    @GetMapping("/getWorkforceList")
    public TableDataInfo getWorkforceList(QueryWorkforceVO vo) {
        startPage();
        System.out.println(vo);
        return getDataTable(schedulingService.getWorkforceList(vo));
    }

    // 修改排班状态
    @PutMapping("/updateWorkforceStatus/{scheduleId}")
    public AjaxResult updateWorkforceStatus(@PathVariable Integer scheduleId) {
        System.out.println(scheduleId);
        return AjaxResult.success(schedulingService.updateWorkforceStatus(scheduleId));
    }

    // 删除排班信息
    @DeleteMapping("/deleteWorkforce/{scheduleId}")
    public AjaxResult deleteWorkforce(@PathVariable Integer scheduleId) {
        System.out.println(scheduleId);
        return AjaxResult.success(schedulingService.deleteWorkforce(scheduleId));
    }

    // 修改排班信息
    @PostMapping("/updateWorkforce")
    public AjaxResult updateWorkforce(@RequestBody UpdateSchedulingVO vo) {
        System.out.println(vo);
        return AjaxResult.success(schedulingService.updateWorkforce(vo));
    }


    // 根据科室获取医生列表
    @GetMapping("/getDoctorListByDepartment/{departmentId}")
    public AjaxResult getDoctorListByDepartment(@PathVariable Integer departmentId) {
        System.out.println(departmentId);
        return AjaxResult.success(schedulingService.getDoctorListByDepartment(departmentId));
    }

    // 新增排班
    @PostMapping("/addWorkforce")
    public AjaxResult addWorkforce(@RequestBody AddSchedulingVO vo) {
        System.out.println(vo);
        return AjaxResult.success(schedulingService.addWorkforce(vo));
    }
}
